{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from zhipuai import ZhipuAI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "client = ZhipuAI(api_key=\"\") # 填写您自己的APIKey\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "response = client.chat.completions.create(\n",
    "    model=\"glm-4\",  # 填写需要调用的模型名称\n",
    "    messages=[\n",
    "        {\"role\": \"user\", \"content\": \"你好\"}\n",
    "    ]\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Completion(model='glm-4', created=1705469304, choices=[CompletionChoice(index=0, finish_reason='stop', message=CompletionMessage(content='你好👋！我是人工智能助手智谱清言，可以叫我小智🤖，很高兴见到你，欢迎问我任何问题。', role='assistant', tool_calls=None))], request_id='8305986848066019209', id='8305986848066019209', usage=CompletionUsage(prompt_tokens=6, completion_tokens=32, total_tokens=38))"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'你好👋！我是人工智能助手智谱清言，可以叫我小智🤖，很高兴见到你，欢迎问我任何问题。'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response.choices[0].message.content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from tool_register import get_tools, run_function, get_tool_desc\n",
    "\n",
    "def run_conv_glm(messages, function_list=None, functions=None, model=\"glm-4\"):\n",
    "    \"\"\"\n",
    "    能够自动执行外部函数调用的Chat对话模型\n",
    "    ：params messages: 必要参数，输入到chat模型的messages参数对象\n",
    "\n",
    "    ：return Chat 模型输出结果\n",
    "    \"\"\"\n",
    "    def is_json_string(s):\n",
    "        try:\n",
    "            json_object = json.load(s)\n",
    "        except ValueError as e:\n",
    "            return False\n",
    "        return True\n",
    "    #如果没有外部函数库，则执行普通的对话任务\n",
    "    if function_list == None:\n",
    "        response = client.chat.completions.create(\n",
    "            model=model,\n",
    "            messages=messages\n",
    "        )\n",
    "        final_response = response.choices[0].message.content\n",
    "    #若存在外部函数库，则需要灵活选取外部函数并进行回答 \n",
    "    else:\n",
    "        # 创建调用外部函数的system_message\n",
    "        messages_with_system = [{\"role\":\"system\", \"content\": get_tool_desc()}]\n",
    "        messages_with_system += messages\n",
    "        # first\n",
    "        response = client.chat.completions.create(\n",
    "            model=model,\n",
    "            messages=messages\n",
    "        )\n",
    "        if not chatMessage.tool_calls:\n",
    "            final_response = chatMessage.content\n",
    "        else:\n",
    "            (tool_call,) = chatMessage.tool_calls\n",
    "            if tool_call.type == \"function\":\n",
    "                observation = run_function(tool_call.function.name, tool_call.function.arguments)\n",
    "            OBSERVATION_MAX_LENGTH = 1024\n",
    "            if isinstance(observation, str) and len(observation) > OBSERVATION_MAX_LENGTH:\n",
    "                observation = observation[:OBSERVATION_MAX_LENGTH] + \" [TRUNCATED]\"\n",
    "            #拼接外部调用结果\n",
    "            messages_with_system.append(chatglm_cpp.ChatMessage(role=\"observation\", content=observation))\n",
    "            # 二次调用\n",
    "            chatMessage = pipeline.chat(\n",
    "                messages_with_system,\n",
    "                max_length=2048,\n",
    "                max_context_length=2048,\n",
    "                do_sample=0.95,\n",
    "                top_k=0,\n",
    "                top_p=0.8,\n",
    "                temperature=0.8,\n",
    "                repetition_penalty=1.0,\n",
    "                num_threads=0,\n",
    "                stream=False,\n",
    "            )\n",
    "            #获取最终结果\n",
    "            final_response = chatMessage.content\n",
    "\n",
    "    return final_response"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from tool_register import get_tools, run_function, get_tool_desc, TOOLS\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "tools = [\n",
    "    {\n",
    "        \"type\": \"function\",\n",
    "        \"function\": {\n",
    "            \"name\": \"get_weather\",\n",
    "            \"description\": \"Get the current weather for `city_name`\",\n",
    "            \"parameters\": {\n",
    "                \"type\": \"object\",\n",
    "                \"properties\": {\n",
    "                    \"city_name\": {\n",
    "                        \"description\": \"The name of the city to be queried\",\n",
    "                        \"type\": \"string\"\n",
    "                    }\n",
    "                },\n",
    "                \"required\": [ \"city_name\" ]\n",
    "            },\n",
    "        }\n",
    "    }\n",
    "]\n",
    "response = client.chat.completions.create(\n",
    "            model=\"glm-4\",\n",
    "            messages=[{\"role\":\"system\", \"content\": \"不要假设或猜测传入函数的参数值。如果用户的描述不明确，请要求用户提供必要信息\"}\n",
    "                      , {\"role\": \"user\", \"content\":\"杭州天气怎么样？\"}],\n",
    "            tools = tools\n",
    "        )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Completion(model='glm-4', created=1705471027, choices=[CompletionChoice(index=0, finish_reason='tool_calls', message=CompletionMessage(content=None, role='assistant', tool_calls=[CompletionMessageToolCall(id='call_8305987981937449168', function=Function(arguments='{\"city_name\":\"杭州\"}', name='get_weather'), type='function')]))], request_id='8305987981937449168', id='8305987981937449168', usage=CompletionUsage(prompt_tokens=143, completion_tokens=15, total_tokens=158))"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Answer the following questions as best as you can. You have access to the following tools:\\n[\\n    {\\n        \"name\": \"random_number_generator\",\\n        \"description\": \"Generates a random number x, s.t. range[0] <= x < range[1]\",\\n        \"parameters\": {\\n            \"type\": \"object\",\\n            \"properties\": {\\n                \"seed\": {\\n                    \"description\": \"The random seed used by the generator\",\\n                    \"type\": \"integer\"\\n                },\\n                \"range\": {\\n                    \"description\": \"The range of the generated numbers\",\\n                    \"type\": \"array\",\\n                    \"items\": [\\n                        {\\n                            \"type\": \"integer\"\\n                        },\\n                        {\\n                            \"type\": \"integer\"\\n                        }\\n                    ]\\n                }\\n            },\\n            \"required\": [\\n                \"seed\",\\n                \"range\"\\n            ]\\n        }\\n    },\\n    {\\n        \"name\": \"get_weather\",\\n        \"description\": \"Get the current weather for `city_name`\",\\n        \"parameters\": {\\n            \"type\": \"object\",\\n            \"properties\": {\\n                \"city_name\": {\\n                    \"description\": \"The name of the city to be queried\",\\n                    \"type\": \"string\"\\n                }\\n            },\\n            \"required\": [\\n                \"city_name\"\\n            ]\\n        }\\n    },\\n    {\\n        \"name\": \"excute_sql\",\\n        \"description\": \"\\\\u6267\\\\u884csql\\\\u8bed\\\\u53e5\\\\uff0c\\\\u5f53\\\\u524d\\\\u6570\\\\u636e\\\\u5e93\\\\u7684\\\\u540d\\\\u79f0\\\\u662f`default_db`, \\\\u4eea\\\\u5668\\\\u8868\\\\u540d\\\\u79f0\\\\u662f\\\\uff1ayqxx\\\\uff0c\\\\u4ee5\\\\u4e0b\\\\u662f\\\\u5b57\\\\u6bb5\\\\u6e05\\\\u5355\\\\uff1aname_ch: \\\\u4eea\\\\u5668\\\\u540d\\\\u79f0\\\\uff0cprop_num: \\\\u8d44\\\\u4ea7\\\\u7f16\\\\u53f7\",\\n        \"parameters\": {\\n            \"type\": \"object\",\\n            \"properties\": {\\n                \"sql\": {\\n                    \"description\": \"\\\\u9700\\\\u8981\\\\u6267\\\\u884c\\\\u7684sql\\\\u8bed\\\\u53e5\"\\n                }\\n            },\\n            \"required\": [\\n                \"sql\"\\n            ]\\n        }\\n    }\\n]'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_tool_desc()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[registered tool] {'function': {'description': 'Generates a random number x, s.t. range[0] <= x '\n",
      "                             '< range[1]',\n",
      "              'name': 'random_number_generator',\n",
      "              'parameters': {'properties': {'city_name': {'description': 'The '\n",
      "                                                                         'name '\n",
      "                                                                         'of '\n",
      "                                                                         'the '\n",
      "                                                                         'city '\n",
      "                                                                         'to '\n",
      "                                                                         'be '\n",
      "                                                                         'queried',\n",
      "                                                          'type': 'string'},\n",
      "                                            'range': {'description': 'The '\n",
      "                                                                     'range of '\n",
      "                                                                     'the '\n",
      "                                                                     'generated '\n",
      "                                                                     'numbers',\n",
      "                                                      'type': 'tuple[int, '\n",
      "                                                              'int]'},\n",
      "                                            'seed': {'description': 'The '\n",
      "                                                                    'random '\n",
      "                                                                    'seed used '\n",
      "                                                                    'by the '\n",
      "                                                                    'generator',\n",
      "                                                     'type': 'int'}},\n",
      "                             'required': ['seed', 'range'],\n",
      "                             'type': 'object'}},\n",
      " 'type': 'function'}\n",
      "[registered tool] {'function': {'description': 'Get the current weather for `city_name`',\n",
      "              'name': 'get_weather',\n",
      "              'parameters': {'properties': {'city_name': {'description': 'The '\n",
      "                                                                         'name '\n",
      "                                                                         'of '\n",
      "                                                                         'the '\n",
      "                                                                         'city '\n",
      "                                                                         'to '\n",
      "                                                                         'be '\n",
      "                                                                         'queried',\n",
      "                                                          'type': 'str'}},\n",
      "                             'required': ['city_name'],\n",
      "                             'type': 'object'}},\n",
      " 'type': 'function'}\n"
     ]
    }
   ],
   "source": [
    "from zhipu_tools_demo.tool_register import get_tools, dispatch_tool"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'type': 'function',\n",
       "  'function': {'name': 'random_number_generator',\n",
       "   'description': 'Generates a random number x, s.t. range[0] <= x < range[1]',\n",
       "   'parameters': {'type': 'object',\n",
       "    'properties': {'city_name': {'description': 'The name of the city to be queried',\n",
       "      'type': 'string'},\n",
       "     'seed': {'description': 'The random seed used by the generator',\n",
       "      'type': 'int'},\n",
       "     'range': {'description': 'The range of the generated numbers',\n",
       "      'type': 'tuple[int, int]'}},\n",
       "    'required': ['seed', 'range']}}},\n",
       " {'type': 'function',\n",
       "  'function': {'name': 'get_weather',\n",
       "   'description': 'Get the current weather for `city_name`',\n",
       "   'parameters': {'type': 'object',\n",
       "    'properties': {'city_name': {'description': 'The name of the city to be queried',\n",
       "      'type': 'str'}},\n",
       "    'required': ['city_name']}}}]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_tools()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "response = client.chat.completions.create(\n",
    "            model=\"glm-4\",\n",
    "            messages=[{\"role\":\"system\", \"content\": \"不要假设或猜测传入函数的参数值。如果用户的描述不明确，请要求用户提供必要信息\"}\n",
    "                      , {\"role\": \"user\", \"content\":\"杭州天气怎么样？\"}],\n",
    "            tools = get_tools()\n",
    "        )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Completion(model='glm-4', created=1705473653, choices=[CompletionChoice(index=0, finish_reason='tool_calls', message=CompletionMessage(content=None, role='assistant', tool_calls=[CompletionMessageToolCall(id='call_8305986882425728941', function=Function(arguments='{\"city_name\":\"杭州\"}', name='get_weather'), type='function')]))], request_id='8305986882425728941', id='8305986882425728941', usage=CompletionUsage(prompt_tokens=314, completion_tokens=15, total_tokens=329))"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "function_call = response.choices[0].message.tool_calls"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[CompletionMessageToolCall(id='call_8305986882425728941', function=Function(arguments='{\"city_name\":\"杭州\"}', name='get_weather'), type='function')]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function_call"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "function = function_call[0].function\n",
    "function_args = json.loads(function.arguments)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'city_name': '杭州'}"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "function_args"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "tool_response = dispatch_tool(function.name, function_args)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"{'current_condition': {'temp_C': '18', 'FeelsLikeC': '18', 'humidity': '42', 'weatherDesc': [{'value': 'Sunny'}], 'observation_time': '04:24 AM'}}\""
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tool_response"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'content': None,\n",
       " 'role': 'assistant',\n",
       " 'tool_calls': [{'id': 'call_8305986882425728941',\n",
       "   'function': {'arguments': '{\"city_name\":\"杭州\"}', 'name': 'get_weather'},\n",
       "   'type': 'function'}]}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response.choices[0].message.model_dump()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "response = client.chat.completions.create(\n",
    "            model=\"glm-4\",\n",
    "            messages=[{\"role\":\"system\", \"content\": \"不要假设或猜测传入函数的参数值。如果用户的描述不明确，请要求用户提供必要信息\"}\n",
    "                      , {\"role\": \"user\", \"content\":\"杭州天气怎么样？\"}\n",
    "                      , response.choices[0].message.model_dump()\n",
    "                      , {\"role\": \"tool\", \"content\": f\"json.dumps(tool_response)\", \"tool_call_id\": function_call[0].id}\n",
    "                      ],\n",
    "            tools = get_tools()\n",
    "        )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Completion(model='glm-4', created=1705474931, choices=[CompletionChoice(index=0, finish_reason='stop', message=CompletionMessage(content='杭州的天气情况是：[在此处插入天气信息]。', role='assistant', tool_calls=None))], request_id='8305988600412785052', id='8305988600412785052', usage=CompletionUsage(prompt_tokens=336, completion_tokens=15, total_tokens=351))"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "response = client.chat.completions.create(\n",
    "            model=\"glm-4\",\n",
    "            messages=[{\"role\":\"system\", \"content\": \"不要假设或猜测传入函数的参数值。如果用户的描述不明确，请要求用户提供必要信息\"}\n",
    "                      , {\"role\": \"user\", \"content\":\"杭州天气怎么样？\"}\n",
    "                      , response.choices[0].message.model_dump()\n",
    "                      , {\"role\": \"tool\", \"content\": f\"json.dumps(tool_response)\", \"tool_call_id\": function_call[0].id}\n",
    "                      , response.choices[0].message.model_dump()\n",
    "                      ],\n",
    "            tools = get_tools()\n",
    "        )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Completion(model='glm-4', created=1705474978, choices=[CompletionChoice(index=0, finish_reason='tool_calls', message=CompletionMessage(content=None, role='assistant', tool_calls=[CompletionMessageToolCall(id='call_8305986985504950965', function=Function(arguments='{\"city_name\":\"杭州\"}', name='get_weather'), type='function')]))], request_id='8305986985504950965', id='8305986985504950965', usage=CompletionUsage(prompt_tokens=349, completion_tokens=15, total_tokens=364))"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "def parse_function_call(model_response,messages):\n",
    "    # 处理函数调用结果，根据模型返回参数，调用对应的函数。\n",
    "    # 调用函数返回结果后构造tool message，再次调用模型，将函数结果输入模型\n",
    "    # 模型会将函数调用结果以自然语言格式返回给用户。\n",
    "    if model_response.choices[0].message.tool_calls:\n",
    "        tool_call = model_response.choices[0].message.tool_calls[0]\n",
    "        args = tool_call.function.arguments\n",
    "        function_result = {}\n",
    "        function_result =  dispatch_tool(tool_call.function.name, json.loads(args))\n",
    "        messages.append({\n",
    "            \"role\": \"tool\", \n",
    "            \"content\": f\"{json.dumps(function_result)}\",\n",
    "            \"tool_call_id\":tool_call.id\n",
    "        })\n",
    "        response = client.chat.completions.create(\n",
    "            model=\"glm-4\",  # 填写需要调用的模型名称\n",
    "            messages=messages,\n",
    "            tools=get_tools(),\n",
    "        )\n",
    "        print(response.choices[0].message)\n",
    "        messages.append(response.choices[0].message.model_dump())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "content=None role='assistant' tool_calls=[CompletionMessageToolCall(id='call_8305986985504954827', function=Function(arguments='{\"city_name\":\"杭州\"}', name='get_weather'), type='function')]\n",
      "content='杭州当前的天气情况是晴朗。温度为18摄氏度，湿度为42%，体感温度也是18摄氏度。这些信息是基于早上4:24的观测数据。' role='assistant' tool_calls=None\n"
     ]
    }
   ],
   "source": [
    "messages = []\n",
    "messages.append({\"role\":\"system\", \"content\": \"不要假设或猜测传入函数的参数值。如果用户的描述不明确，请要求用户提供必要信息\"})\n",
    "messages.append({\"role\": \"user\", \"content\":\"杭州天气怎么样？\"})\n",
    "response = client.chat.completions.create(\n",
    "            model=\"glm-4\",\n",
    "            messages=messages,\n",
    "            tools = get_tools()\n",
    "        )\n",
    "print(response.choices[0].message)\n",
    "messages.append(response.choices[0].message.model_dump())\n",
    "parse_function_call(response, messages=messages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "content=None role='assistant' tool_calls=[CompletionMessageToolCall(id='call_8305988119376403500', function=Function(arguments='{\"city_name\":\"北京\"}', name='get_weather'), type='function')]\n",
      "content='北京当前的天气情况是部分多云。温度为2摄氏度，湿度为60%，体感温度为1摄氏度。这些信息是基于早上5:59的观测数据。' role='assistant' tool_calls=None\n"
     ]
    }
   ],
   "source": [
    "messages.append({\"role\": \"user\", \"content\":\"那北京呢？\"})\n",
    "response = client.chat.completions.create(\n",
    "            model=\"glm-4\",\n",
    "            messages=messages,\n",
    "            tools = get_tools()\n",
    "        )\n",
    "print(response.choices[0].message)\n",
    "messages.append(response.choices[0].message.model_dump())\n",
    "parse_function_call(response, messages=messages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "content='不，杭州不比北京更冷。根据最新的天气数据，杭州的温度是18摄氏度，而北京的温度是2摄氏度。所以北京比杭州更冷。' role='assistant' tool_calls=None\n"
     ]
    }
   ],
   "source": [
    "messages.append({\"role\": \"user\", \"content\":\"杭州比北京更冷吗？\"})\n",
    "response = client.chat.completions.create(\n",
    "            model=\"glm-4\",\n",
    "            messages=messages,\n",
    "            tools = get_tools()\n",
    "        )\n",
    "print(response.choices[0].message)\n",
    "messages.append(response.choices[0].message.model_dump())\n",
    "parse_function_call(response, messages=messages)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "chatglm3-demo",
   "language": "python",
   "name": "chatglm3-demo"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
